package com.controller;

import com.util.Constants;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

//交换机
@RestController
@RequestMapping("/producer")
public class Producer {
    @Resource
    public RabbitTemplate rabbitTemplate;

    @RequestMapping("/send")
    public String send(@RequestParam("message") String message) {
        rabbitTemplate.convertAndSend(Constants.EXCHANGE_NAME, Constants.ROUTING_KEY, message);
        return "发送成功";
    }
}
